function getCookie(name) {
    // http://kevin.vanzonneveld.net
    // +   original by: mole
    // -    depends on: urldecode
    // *     example 1: getCookie('_JJP_')
    var result = null,
        myCookie = document.cookie + ";",
        searchName = name + "=",
        start = myCookie.indexOf(searchName),
        end;
    if (start > -1) {
        start += searchName.length;
        end = myCookie.indexOf(";", start);
        result = urldecode(myCookie.substring(start, end));
    }
    return result;
}